<?php

    if (!defined('BASEPATH'))
        exit('No direct script access allowed');

    class page extends MY_Controller {

        private $excID = array(
            22 => 12,
            23 => 6,
            24 => 14,
            25 => 16,
            26 => 13,
            27 => 15
        );
        private $transfID = array(
            29 => 9,
            30 => 10,
            31 => 11
        );
        private $topofferID = array(
            39 => 21,
            45 => 22
        );
        private $cipaID = array(
            32 => 7,
            33 => 8,
            34 => 17,
            35 => 20,
            36 => 18,
            37 => 19,
            43 => 34
        );

        public function __construct() {
            parent::__construct();

            $this->load->helper('gallery');
        }

        public function excursions() {

            $ID = 24;
            $child_post = $this->findPost($ID);

            $data['page'] = $child_post;
            $data['posts'] = $this->findCategoryPosts($child_post['category_ID'], NULL, NULL, $ID);
            $data['files'] = $this->icms->find_files($ID);

            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

            shuffle($data['posts']);

            $this->firephp->log($data);

            $this->template->load('excursions/view_all', $data);
        }

        public function excursion_view($excursion) {

            $ID = idFromUrl($excursion, '-');

            if (isset($this->excID[$ID]))
                $ID = $this->excID[$ID];

            $child_post = $this->findPost($ID);

            $data['page'] = $child_post;
            $data['posts'] = $this->findCategoryPosts($child_post['category_ID'], NULL, NULL, 24);
            $data['photos'] = $this->icms->find_photos($ID);
            $data['files'] = $this->icms->find_files($ID);

            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

//            shuffle($data['posts']);
//            $this->firephp->log($data['files']);

            $this->template->load('excursions/view', $data);
        }

        public function rentacar() {

            $data['seo_title'] = lang('nav.rentacar') . ' | Cipatravel';
            $data['seo_description'] = lang('nav.rentacar') . ' | Cipatravel';
            $data['seo_keywords'] = lang('nav.rentacar') . ' | Cipatravel';

            $this->template->load('rentacar/view', $data);
        }

        public function transfers() {

            $ID = 23;
            $child_post = $this->findPost($ID);

            $data['page'] = $child_post;
            $data['posts'] = $this->findCategoryPosts($child_post['category_ID'], NULL, NULL, $ID);
            $data['files'] = $this->icms->find_files($ID);


            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

//            shuffle( $data['posts']);

            $this->template->load('transfers/view_all', $data);
        }

        public function transfers_view($transfer) {

            $ID = idFromUrl($transfer, '-');

            if (isset($this->transfID[$ID]))
                $ID = $this->transfID[$ID];

            $child_post = $this->findPost($ID);

            $data['page'] = $child_post;
            $data['posts'] = $this->findCategoryPosts($child_post['category_ID'], NULL, NULL, 23);
            $data['photos'] = $this->icms->find_photos($ID);
            $data['files'] = $this->icms->find_files($ID);

            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

            $this->template->load('transfers/view', $data);
        }

        public function links() {

            $data['seo_title'] = 'Links';
            $data['seo_description'] = 'Links';
            $data['seo_keywords'] = 'Links';

            $this->template->load('cipatravel/links', $data);
        }

        public function cipatravel($page) {

            $ID = idFromUrl($page, '-');

            if (isset($this->cipaID[$ID]))
                $ID = $this->cipaID[$ID];

            $child_post = $this->findPost($ID);


            $data['page'] = $child_post;
            $data['photos'] = $this->icms->find_photos($ID);
            $data['files'] = $this->icms->find_files($ID);

            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

            $this->template->load('cipatravel/view', $data);
        }

        public function top_offer() {

            $post_ID = 25;
            $child_post = $this->findPost($post_ID);

            $data['page'] = $child_post;
            $data['posts'] = $this->findCategoryPosts($child_post['category_ID'], NULL, NULL, 25);
            $data['files'] = $this->icms->find_files($post_ID);
            $data['photos'] = $this->icms->find_photos($post_ID);

            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

//            shuffle($data['posts']);

            $this->firephp->log($data['page']);

            $this->template->load('top_offer/view_all', $data);
        }

        public function top_offer_view($post_ID) {

            $post_ID = idFromUrl($post_ID, '-');

            if (isset($this->topofferID[$post_ID]))
                $post_ID = $this->topofferID[$post_ID];

            $child_post = $this->findPost($post_ID);

            $data['page'] = $child_post;
            $data['posts'] = $this->findCategoryPosts($child_post['category_ID'], NULL, NULL, 25);
            $data['files'] = $this->icms->find_files($post_ID);
            $data['photos'] = $this->icms->find_photos($post_ID);

            $data['seo_title'] = $data['page']['seo_title'] != "" ? $data['page']['seo_title'] : $data['page']['title'];
            $data['seo_description'] = $data['page']['seo_description'];
            $data['seo_keywords'] = $data['page']['seo_keywords'];

//            shuffle($data['posts']);
//            $this->firephp->log($data['posts']);

            $this->template->load('top_offer/view', $data);
        }

    }
    